package com.jvm.chapter2;

/**
 * 3-5 新生代minorGC
 * vm option:   -verbose:gc -Xms20M -Xmx20M -Xmn10M -XX:+PrintGCDetails -XX:SurvivorRatio=8
 * -XX:+UseSerialGC 指定收集器
 * java -verbose[:class|gc|jni] 在输出设备上显示虚拟机运行信息。
 * -Xmn  年轻代大小
 * -XX:SurvivorRatio=8   eden和survior大小比例
 * Created by 85243 on 2017/4/16.
 * -verbose:gc -XX:+UseSerialGC -XX:+PrintGCDetails  -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./java_pid%p.hprof
 * --XX:PretenureSizeThreshold 将对象大小这个值的直接放到老年代
 */
public class Demo7 {
    private static final int _1MB = 1024 * 1024;

    public static void main(String[] args) throws InterruptedException {
        byte[] allocation1 ,allocation2 ,allocation3,allocation4;
//        System.gc();
        allocation1 = new  byte[2*_1MB];
        allocation2 = new  byte[2*_1MB];
        allocation3 = new  byte[2*_1MB];
        allocation4 = new  byte[4*_1MB];
//        allocation4 = new  byte[4*_1MB];
        System.out.println("--------------------");
//        System.gc();
//        Thread.sleep(10000);
    }
}

/**
 * output
 *
 * [GC (Allocation Failure) [DefNew: 7846K->431K(9216K), 0.0062309 secs] 7846K->6575K(19456K), 0.0062643 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
 * --------------------
 * Heap
 *  def new generation   total 9216K, used 4768K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
 *   eden space 8192K,  52% used [0x00000000fec00000, 0x00000000ff03c3c8, 0x00000000ff400000)
 *   from space 1024K,  42% used [0x00000000ff500000, 0x00000000ff56bdc8, 0x00000000ff600000)
 *   to   space 1024K,   0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
 *  tenured generation   total 10240K, used 6144K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
 *    the space 10240K,  60% used [0x00000000ff600000, 0x00000000ffc00030, 0x00000000ffc00200, 0x0000000100000000)
 *  Metaspace       used 3227K, capacity 4496K, committed 4864K, reserved 1056768K
 *   class space    used 346K, capacity 388K, committed 512K, reserved 1048576K
 */
